﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Cartoon.Skin
{
    public class SkinService : ISkinService
    {
         
        public SkinService()
        {
            //this.LoadSkin("Default");
            this.LoadSkin("SiShen");
        }

        #region ISkinService 成员

        protected ISkin _Skin;
        public ISkin Skin
        {
            get { return this._Skin; }
        }

        public event Action Changed;
        protected void OnChanged()
        {
            if (this.Changed != null)
            {
                this.Changed();
            }
        }

        public void LoadSkin(string skinname)
        {
            ISkin oldSkin = this._Skin;
            this._Skin = SkinFactory.GetSkin(skinname);

            if (oldSkin != null && oldSkin.SkinName != this._Skin.SkinName)
            {
                this.OnChanged();
            }
        }
        #endregion
    }
}
